<?php
	require_once('../includes/config.php');
	$cmn_query = "SELECT * FROM tbl_comment ORDER BY id";
	$currentPage = strstr($_SERVER['REQUEST_URI'],'index');
	$itemperPage = 15;
	$result = mysql_query(_getPagingQuery("$cmn_query", $itemperPage));
	$totalpage = _totalpage("$cmn_query", $itemperPage);
	$pages = paginate ("index.php?view=comment", "page", $totalpage, $currentPage, $itemperPage);
?>
<script type="text/javascript">
$(document).ready(function() {
	//load popup to edit
	$(".edit").click(function(){
		centerPopup();
		loadPopup();
		page=$(this).attr("href");
		$("#popupComment").html("loading...").load(page);
		return false;
	});	
	$(".del").click(function(){
		el=$(this);
		if(confirm("Are you sure?"))
		{
			$.ajax({
				url:$(this).attr("href"),
				type:"POST",
				dataType: 'json',
				success:function(data)
				{
					if(data==1)
					{
						el.parent().parent().fadeOut('slow');
					}
					else
					{
						alert(data);
					}
				}
			})
		}
		return false;
	});
});
</script>
<table id="rounded-corner" summary="2007 Major IT Companies' Profit">
    <thead>
    	<tr>
        	<th scope="col" class="rounded-company"></th>
            <th scope="col" class="rounded">Product Name</th>
            <th scope="col" class="rounded">Comment Content</th>
            <th scope="col" class="rounded">Date</th>
            <th scope="col" class="rounded">Edit</th>
            <th scope="col" class="rounded-q4">Delete</th>
        </tr>
    </thead>
    <tbody>
    <?php 
		if(mysql_num_rows($result)>0)
		{
			while($row = mysql_fetch_assoc($result))
			{
				extract($row);
	?>
    	<tr>
        	<td><input type="checkbox" name="" /></td>
            <td><a target="_blank" href="../index.php?mod=product&act=detail&id=<?php echo $id_product; ?>"><?php echo _GetProductName($id_product); ?></a></td>
            <td><a target="_blank" href="../index.php?mod=product&act=detail&id=<?php echo $id_product; ?>#comment-<?php echo $id; ?>"><?php echo $comment_content ?></a></td>
            <td><?php echo $dateadded; ?></td>
            <td><a href="comment_f.php?act=edit&id=<?php echo $id; ?>" class="edit"><img src="templates/images/user_edit.png" alt="" title="" border="0" /></a></td>
            <td><a href="comment_process.php?act=del&id=<?php echo $id; ?>" class="del"><img src="templates/images/trash.png" alt="" title="" border="0" /></a></td>
        </tr>
        <?php
			}
		}
		else echo "Do not have any comment yet";
		?>
    </tbody>
</table>
